Visual Basic (Declaration) | |
---|---|
Public Overloads Sub AddFilter(Of T As Class)( _ ByVal transformFunc As Func(Of IQueryable(Of T),IQueryable(Of T)), _ Optional ByVal canReplaceIfAlreadyExists As Boolean _ ) |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As EntityQueryFilterCollection Dim transformFunc As Func(Of IQueryable(Of T),IQueryable(Of T)) Dim canReplaceIfAlreadyExists As Boolean instance.AddFilter(Of T)(transformFunc, canReplaceIfAlreadyExists) |
C# | |
---|---|
public void AddFilter<T>( Func<IQueryable<T>,IQueryable<T>> transformFunc, bool canReplaceIfAlreadyExists ) where T: class |
C++/CLI | |
---|---|
public: void AddFiltergeneric<typename T> ( Func<IQueryable<T^>^,IQueryable<T^>^>^ transformFunc, bool canReplaceIfAlreadyExists ) where T: ref class |
Parameters
- transformFunc
- A Func that takes and returns an IQueryable{T}
- canReplaceIfAlreadyExists
Type Parameters
- T
- Entity type
Exception | Description |
---|---|
System.ArgumentException | Thrown if a filter for the entity type is already in the collection and the canReplaceIfAlreadyExists paremter is set to false |
C# | ![]() |
---|---|
public void FilteringSample() { // Query for all customers. A filter will be applied prior to execution. var mgr = new DomainModelEntityManager(); var list = mgr.Customers.ToList(); } // Server-side implementation of EntityServerQueryInterceptor public class EntityServerQueryManager : EntityServerQueryInterceptor { protected override bool FilterQuery() // Add filters QueryFilters.AddFilter<Customer>(q => q.Where(c => c.Country == "USA")); QueryFilters.AddFilter<Employee>(q => q.Where(e => e.Country == "USA")); return true; } } |
The transformFunc, although it looks intimidating, is really a simple Where predicate which you're already familiar with when using query expression syntax. See the example for more information.
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family